package com.atguigu.java;

/**
 *
 * 创建三个窗口卖票，总票数为100张，使用 Runnable 接口的方式
 * @Description
 * @Author codingBee
 * @Date 2020/8/21/7:04
 */
public class WindowTest1 {
    public static void main(String[] args) {
        Window1 window1 = new Window1();
        Thread thread1 = new Thread(window1,"窗口1");
        Thread thread2 = new Thread(window1,"窗口2");
        Thread thread3 = new Thread(window1,"窗口3");
        thread1.start();
        thread2.start();
        thread3.start();
    }
}
class Window1 implements Runnable{
    private int  ticket = 100;
    @Override
    public void run() {
        while(true){
            if (ticket>0){
                System.out.println(Thread.currentThread().getName() + ":卖票，票号为：" + ticket);
                ticket--;
            }else{
                break;
            }
        }

    }
}
